package com.zjk.service.impl;

import com.github.pagehelper.PageHelper;
import com.zjk.dao.UserMapper;
import com.zjk.pojo.SysUser;
import com.zjk.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysUserServiceImpl implements ISysUserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public SysUser getUserNyUsernameAndPwd(SysUser sysUser) {
        SysUser sysUser1 = userMapper.getUserNyUsernameAndPwd(sysUser);
        return sysUser1;
    }

    @Override
    public List<SysUser> getAllUsers(String username,Integer pageNum,Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<SysUser> allUsers = userMapper.getAllUsers(username);
        return allUsers;
    }

    @Override
    public SysUser getUserById(Integer id) {
        SysUser user = userMapper.getUserById(id);
        return user;
    }

    @Override
    public int addUser(SysUser sysUser) {
        int i = userMapper.addUser(sysUser);
        return i;
    }

    @Override
    public int editUser(SysUser sysUser) {
        int i = userMapper.editUser(sysUser);
        return i;
    }

    @Override
    public int delById(Integer id) {
        int i = userMapper.delById(id);
        return i;
    }

    @Override
    public int delAll(List<Integer> ids) {
        int i = userMapper.delAll(ids);
        return i;
    }

    @Override
    public SysUser getUserByUsername(String username) {
        SysUser user = userMapper.getUserByUsername(username);
        return user;
    }
}
